<%@page import="oracle.sql.CLOB"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" 
		trimDirectiveWhitespaces="true"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>



<!-- 수정하기 전 내용 불러오는 sql -->
<sql:query var="rs" dataSource="jdbc/oracle11xe">
	select *
	from BOARD
	where bdno = ?
	<sql:param value="${param.bdno}"/>
</sql:query>

<!-- 보안코드 -->
<c:if test="${empty sessionScope.login}">
	<c:redirect url="login.jsp"/>
</c:if>

<style type="text/css">
#updatefrm {
	width: 700px;
	margin: 0 auto;
}
#updatefrm div{
	margin:10px 5px;
}
#updatefrm div label {
	display: inline-block;
	width: 120px;
	text-align: right;
	font-weight: bold;
	padding: 0 10px 10px 0;
}
#bdcontents{
	width:350px;
	height:275px;
}

.dragup{
	vertical-align:top;
}

</style>
	<div id="contents">
	<h2>게시판 수정</h2>
	<c:forEach var="r" items="${rs.rows}">
	<c:set var="contents" scope="request" value="${r.contents}"/>
	<% CLOB clob = (CLOB)request.getAttribute("contents"); 
	try{
		String tmp = clob.getSubString(1,(int)clob.length());
		request.setAttribute("ncontents",tmp);
	}catch(Exception ex){
	}%>
		<!-- 본문 출력 시작 -->
		<form name="updatefrm" id="updatefrm" >
			<div>
				<label>제목</label> 
				<span><input type="text" name="bdtitle" id="bdtitle" value="${r.bdtitle}" /></span>
			</div>
			<div>
				<label>작성자</label> 
				<span><input type="text" name="userid" id="userid" disabled="disabled" value="${r.userid}"/></span>
			</div>
			<div>
				<label class="dragup">본문</label> 
				<span><textarea id="bdcontents" name="contents">${ncontents}</textarea></span>
			</div>
			<!-- 버튼들 -->
			<div>
				<label></label>
				<span>
				<button type="button" id="updokBtn">수정완료</button>
				<button type="reset" >다시입력</button>
				<button type="button" id="listBtn">목록보기</button>
				</span>
			</div>	
	</form>
	</c:forEach>
	<input type="hidden" id="bdno" value="${param.bdno}"/>
		<%--view.jsp?bdno=xxx를 통해 update.jsp로 전파된 bdno를 updateok.jsp로
			bdno를 전파하기 위해 숨김필드로 작성함 
			이렇게 전파된 bdno는 javascript의 getElementById를 이용해 질의문자열을 생성함--%>
</div>
	
	<script src="js/jquery-1.11.1.min.js"></script>
	<script src="js/jech913.js"></script>	
</body>
</html>